import { BasicRemoveParams } from '../model/baseModel';
import {
  UserListGetResultModel,
  UserListItem,
  //------------
  AccountParams,
  DeptListItem,
  MenuParams,
  RoleParams,
  RolePageParams,
  MenuListGetResultModel,
  DeptListGetResultModel,
  AccountListGetResultModel,
  RolePageListGetResultModel,
  RoleListGetResultModel, RepeatValidaParam, UserParams,
} from './model/systemModel'

import { defHttp } from '/@/utils/http/axios'

enum Api {
  UserList = '/user/listUser',
  getUser = '/user/getUserById',
  isAccountExit='/user/isAccountExit',
  UpdateUser = '/user/updateUser',
  AddUser = '/user/register',
  RemoveUser = '/user/removeUser',
  UpdatePassword = '/user/updatePassword',
  //=========================================
  AccountList = '/system/getAccountList',
  DeptList = '/system/getDeptList',
  setRoleStatus = '/system/setRoleStatus',
  MenuList = '/system/getMenuList',
  RolePageList = '/system/getRoleListByPage',
  GetAllRoleList = '/role/getAllRoleList'
}
export const listUser = (params: AccountParams) => {
  return defHttp.post<UserListGetResultModel>({url: Api.UserList, params});
};
export const removeUser = (params:BasicRemoveParams)=>{
  return defHttp.post({url:Api.RemoveUser,params})
}
export const getUserById = (userId: string) => {
   return defHttp.get<UserListItem>({ url:Api.getUser,params:{userId}})
}
export const updateUser = (params:UserParams)=>{
  return defHttp.post({url:Api.UpdateUser,params})
}
export const addUser = (params: UserParams) => {
  return defHttp.post({url:Api.AddUser,params})
};
export const isAccountExit = (params:RepeatValidaParam)=>{
  return defHttp.post({url:Api.isAccountExit,params})
}
export const updatePassword = (params:UserParams)=>{
  return defHttp.post({url:Api.UpdatePassword,params})
}
//---------------------------------------------------
export const getAccountList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params })
export const getDeptList = (params?: DeptListItem) =>
  defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params })

export const getMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params })

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params })

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params })

export const setRoleStatus = (id: number, status: string) =>
  defHttp.post({ url: Api.setRoleStatus, params: { id, status } })

